package reflect;

public class ArgsDemo {
    public static void main(String[] args) {
        //jdk1.5之后推出特性：变长参数
        /*
        编译时会被编译为数组类型
        doSome(new String[]{"1"});
        doSome(new String[]{"1","2"});
        doSome(new String[]{"1","2","3"});
        * */
        doSome("1");
        doSome("1","2");
        doSome("1","2","3");
        doSome("1","2","3","4");
    }
    //public static void doSome(String[] arg){}
    public static void doSome(String... arg){//变长参是编译器认可的，编译后会将变长参改为数组类型，该参数只能是方法的最后一个参数
        System.out.println(arg.length);
    }
}
